package chapter14.nullperson;

/**
 * @author : DuJiabao
 * @Date : 2021/2/25 16:37
 * @Project : thinking_in_java
 * @File : null.java
 * @Desc :
 */
public class Position {
  private String title;
  private Person person;

  public Position(String title, Person person) {
    this.title = title;
    if (person == null)
      person = Person.NULL;
    this.person = person;
  }

  public Position(String title) {
    this.title = title;
    person = Person.NULL;
  }

  public String getTitle() {
    return title;
  }

  public void setTitle(String title) {
    this.title = title;
  }

  public Person getPerson() {
    return person;
  }

  public void setPerson(Person person) {
    if (person == null)
      person = Person.NULL;
    this.person = person;
  }

  @Override
  public String toString() {
    return "Position{" +
            "title='" + title + '\'' +
            ", person=" + person +
            '}';
  }
}
